using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FiltronASP.Modules.Abstracts;
using FiltronASP.Models.DAO.Interfaces;
using FiltronASP.Models;

namespace FiltronASP.Modules
{
    public class mainSliderModule : AbstractModule
    {

        /// <summary>
        /// Klasa odpowiedzialna za generowanie contentu przez modul.
        /// </summary>
        /// <param name="page">biezaca strona</param>
        /// <returns>content</returns>
        public override string GenerateContent(FiltronASP.Models.Page page)
        {
            if (page == null)
            {
                return "<ul></ul>";
            }   //if
            Models.DAO.GalleryImageDAO galleryImageDAO = new Models.DAO.GalleryImageDAO();
            String htmlToReturn = "<ul>";
            String galleryName = "mainSlider";
            IQueryable<GalleryImage> galleryImages = galleryImageDAO.FindByGalleryNameAndPage(galleryName, page.page_id);
            if (galleryImages != null)
            {
                foreach (GalleryImage image in galleryImages)
                {
                    htmlToReturn += string.Format("<li><a href=\"{0}\"><img src=\"{1}\" alt=\"{2}\" /></a></li>", "", image.gallery_image_link, image.gallery_image_info);
                }   //foreach
            }   //if
            htmlToReturn += "</ul>";
            return htmlToReturn;
        }
    }
}
